<!DOCTYPE html>
<html>
<head>
    <title>备件选择清单</title>
    #parse("sys/header.html")
</head>
<body>
<div id="rrapp" v-cloak>
    <div>
        <Row :gutter="16" style="margin: 8px 0px 0px 1px">
            <div class="search-group">
                <i-col span="4">
                    <i-input v-model="q.name" @on-enter="query" placeholder="名称"/>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>
        <table id="jqGrid"></table>
    </div>
</div>
<script>
    $(function () {
        $("#jqGrid").Grid({
            url: '../modulesp/list',
            colModel: [
                {label: '系统编码', name: 'partCode', index: 'PART_CODE', width: 60},
                {label: '备件名称', name: 'name', index: 'NAME'},
                {label: '图号', name: 'mapNo', index: 'MAP_NO'},
                {label: '适用产品类别', name: 'type', index: 'TYPE', width: 80},
                {label: '条码代码', name: 'uniqueBarCode', index: 'UNIQUE_BAR_CODE', width: 60},
                {
                    label: '最近一次批次制定时间', name: 'lastPurchaseDate', index: 'LAST_PURCHASE_DATE', formatter: function (value) {
                        return transDate(value, "yyyy-MM-dd hh:mm:ss");
                    }
                },
                {label: '备注', name: 'remark', index: 'REMARK', width: 120},
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
            ]
        });
    });
    let vm = new Vue({
        el: '#rrapp',
        data: {
            q: {
                name: ''
            }
        },
        methods: {
            query: function () {
                vm.reload();
            },
            reload: function (event) {
                let page = $("#jqGrid").jqGrid('getGridParam', 'page');
                $("#jqGrid").jqGrid('setGridParam', {
                    postData: vm.q,
                    page: page
                }).trigger("reloadGrid");
            },
            reloadSearch: function () {
                vm.q = {
                    name: ''
                };
                vm.reload();
            }
        }
    });

    var getSparePart = function () {
        return getSelectedRowData('#jqGrid');
    }
</script>
</body>
</html>
